#pragma once
#include <iostream>
typedef struct BiTree {
	int data;
	BiTree* left;
	BiTree* right;
	bool ltag;
	bool rtag;
}BiTree;

void InitTree(BiTree* node)
{
	node->left = nullptr;
	node->right = nullptr;
	node->ltag = 0;
	node->rtag = 0;
}

void preorder(BiTree* node, BiTree*& pre)
{
	preorder(node->left, node);
	if (node == nullptr)
		return;
	std::cout << node->data << std::endl;
	if (pre->right == nullptr)
	{
		pre->right = node;
		pre->rtag = 1;
	}
	if (node->left == nullptr)
	{
		pre->left = pre;
		pre->ltag = 1;
	}
	preorder(node->right, node);
}